<%@ page language="java" import="java.util.*,java.io.*,jxl.Workbook,java.text.*" pageEncoding="utf-8"%>
<%@ page import="jxl.format.Colour,jxl.format.Alignment,jxl.format.UnderlineStyle,jxl.format.VerticalAlignment,jxl.write.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>       
    <title>日监控报表导出</title>    
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>  
  <body> 
  <%
     HttpSession httpSession = request.getSession();
     List<Object> UrgeListRows=new ArrayList<Object>();
     UrgeListRows=(List)httpSession.getAttribute("UrgeListRows");
		try {
			OutputStream os = response.getOutputStream();// 取得输出流
			response.reset();// 清空输出流
			response.setHeader("Content-disposition", "attachment; filename="
					+ new String("催收报表".getBytes("GB2312"), "8859_1")
					+ ".xls");// 设定输出文件头
			response.setContentType("application/msexcel");// 定义输出类型
			WritableWorkbook wwb = Workbook.createWorkbook(os); // 建立excel文件
			jxl.write.WritableSheet ws = null;
			ws = wwb.createSheet("催收报表", 1);							
			WritableFont wf = new WritableFont(WritableFont.ARIAL, 12,
					WritableFont.NO_BOLD, false,
					UnderlineStyle.NO_UNDERLINE, Colour.WHITE);
			WritableCellFormat wcf = new WritableCellFormat(wf);
			wcf.setVerticalAlignment(VerticalAlignment.CENTRE);
			wcf.setAlignment(Alignment.CENTRE);
			wcf.setBackground(Colour.BROWN);
			wcf.setBorder(jxl.format.Border.ALL,
					jxl.format.BorderLineStyle.MEDIUM, Colour.ICE_BLUE);
			WritableFont wf1 = new WritableFont(WritableFont.ARIAL, 12,
					WritableFont.NO_BOLD, false,
					UnderlineStyle.NO_UNDERLINE, Colour.BLACK);
			WritableCellFormat wcf1 = new WritableCellFormat(wf1);
			wcf1.setVerticalAlignment(VerticalAlignment.CENTRE);
			wcf1.setAlignment(Alignment.CENTRE);
			wcf1.setBackground(Colour.WHITE);
			wcf1.setBorder(jxl.format.Border.ALL,
					jxl.format.BorderLineStyle.MEDIUM, Colour.ICE_BLUE);
			int i = 0;
			int j = 0;
			ws.mergeCells(0, 0, 0, 0);
			ws.mergeCells(1, 0, 1, 0);
			ws.mergeCells(2, 0, 2, 0);
			ws.mergeCells(3, 0, 3, 0);
			ws.mergeCells(4, 0, 4, 0);
			ws.mergeCells(5, 0, 5, 0);
			ws.mergeCells(6, 0, 6, 0);																																						
			ws.addCell(new Label(0, 0, "催收时间", wcf));
			ws.addCell(new Label(1, 0, "问题发生时间", wcf));
			ws.addCell(new Label(2, 0, "催收对象代码", wcf));
			ws.addCell(new Label(3, 0, "催收对象名称", wcf));
			ws.addCell(new Label(4, 0, "催收问题", wcf));
			ws.addCell(new Label(5, 0, "催收结果", wcf));
			ws.addCell(new Label(6, 0, "催收结果内容记录", wcf));			
			if ((UrgeListRows!=null) || (UrgeListRows.size()==0)){                
               for(int k=0;k<UrgeListRows.size();k++){
                   String s=UrgeListRows.get(k).toString();
                   s=s.replace("]","");
                   s=s.replace("[","");
                   String[] m=s.trim().split(",");
                   if (m[0]!=null)
                       ws.addCell(new Label(0, j + i + 1, (String)m[0].trim(), wcf1));
                   else
                       ws.addCell(new Label(0, j + i + 1, "", wcf1));
                   if (m[1]!=null)
                       ws.addCell(new Label(1, j + i + 1, (String)m[1].trim(), wcf1));
                   else
                       ws.addCell(new Label(1, j + i + 1, "", wcf1));
                   if (m[2]!=null)
                       ws.addCell(new Label(2, j + i + 1, (String)m[2].trim(), wcf1));
                   else
                       ws.addCell(new Label(2, j + i + 1, "", wcf1));
                   if (m[3]!=null)
                       ws.addCell(new Label(3, j + i + 1, (String)m[3].trim(), wcf1));
                   else
                       ws.addCell(new Label(3, j + i + 1, "", wcf1));
                   if (m[4]!=null)
                       ws.addCell(new Label(4, j + i + 1, (String)m[4].trim(), wcf1));
                   else
                       ws.addCell(new Label(4, j + i + 1, "", wcf1));
                   if (m[5]!=null)
                       ws.addCell(new Label(5, j + i + 1, (String)m[5].trim(), wcf1));
                   else
                       ws.addCell(new Label(5, j + i + 1, "", wcf1));
                   if (m[6]!=null)
                       ws.addCell(new Label(6, j + i + 1, (String)m[6].trim(), wcf1));
                   else
                       ws.addCell(new Label(6, j + i + 1, "", wcf1));                   
                   i++;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
               }
            }
			wwb.write();
			wwb.close();
			os.flush();
			os.close();			
		} catch (Exception e) {// 第一层循环
			e.printStackTrace();
		}                       
  %>
  </body>
</html>
